/**
 *  @file Random.h
 */
#ifndef _RANDOM_H_
#define _RANDOM_H_

#include "../common/BaseObject.h"
#include "../collections/ArrayT.h"

namespace cppflib
{

class CFString;

namespace util
{

/**
 *  A class to generate random number
 */
class _DLLAPI Random : public BaseObject
{
public:
    typedef enum {
       RT_HEXDIGIT,        // hex digits only
       RT_DECDIGIT,        // decimal digits only
       RT_ALPHANUMERIC,    // alphabets and decimal digits
       RT_ALPHANUMERIC_NOCASE,    // alphabets (upper and lower case) and decimal digits
       RT_UPPERCASE,       // upper case English letters only
       RT_LOWERCASE,       // lower case English letters only
    } randtype_t;

private:
    ptr_t handle;

private:
    void InitHandle();
    void Close();
    void ReleaseBeforeThrowing();

public:
    Random(void);
    virtual ~Random(void);

    int GetInt32();
    int GetInt32(int min, int max);
    i64_t GetInt64();
    i64_t GetInt64(i64_t min, i64_t max);

    void GetBytes(collections::ArrayByte &buf);
    void GetBytes(collections::ArrayByte &buf, int offset, int count);
    void GetString(CFString &str, randtype_t type, int num);
};

} // end of namespace util

} // end of namespace cppflib

#endif
